package com.richapp.launcher.ui.activities;

import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;
import android.widget.VideoView;

import com.richapp.launcher.R;
import com.richapp.launcher.common.AdvType;
import com.richapp.launcher.dao.adv.Adv;
import com.richapp.launcher.service.AdvService;

import java.util.List;

/**
 * Created by yif on 16/9/13.
 */
public class BootAdvActivity extends Activity {

    private VideoView videoView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);  //设置全屏

        setContentView(R.layout.activity_boot_adv);

        videoView = (VideoView) findViewById(R.id.videoView);

        List<Adv> advs = AdvService.advMap.get(AdvType.BOOT_TYPE);


        Uri uri = null;
        if (advs != null && !advs.isEmpty()) {
            uri = Uri.parse("android.resource://" + getPackageName() + "/files/adv/" + advs.get(0).getId());
        } else {
            uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.boot);
        }
        videoView.setVideoURI(uri);
        Log.e(BootAdvActivity.class.getName(), uri.toString());
        videoView.start();
    }
}
